<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .target {
      width: 200px;
      height: 200px;
      border: 1px solid black;
      font-size: 30px;
      text-align: center;
      line-height: 200px;
    }
  </style>
</head>

<body>
  <div class="box">hello!</div>
</body>

</html>
<script>
  //获取div元素
  var box = document.querySelector('.box')
  //获取的div元素设置className
  box.className = 'target'
</script>